package com.crazy.model.major.dto;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author zhaochaofeng
 * @version 1.0
 * @date 2020/11/19 16:26
 */
@Data
public class Menu implements Comparable<Menu>, Serializable {

    private Long id;
    private Long parentId;
    /**
     * 菜单名称
     */
    private String menuName;
    /**
     * 请求地址
     */
    private String url;
    /**
     * 子菜单
     */
    private List<Menu> subMenus;
    private Integer orderNo;

    public Menu(){}
    public Menu(Long id, Long parentId, String menuName) {
        this.id = id;
        this.parentId = parentId;
        this.menuName = menuName;
    }

    @Override
    public int compareTo(Menu o) {
        if(this.getOrderNo() == null){return 1;}
        if(o.getOrderNo() == null){return -1;}
        if(this.getOrderNo().intValue() > o.getOrderNo().intValue()) {
            return 1;
        }else{
            return -1;
        }
    }
}
